package com.hig.risk.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hig.risk.mapper.RiskSelfInspectionContentMapper;
import com.hig.risk.domain.RiskSelfInspectionContent;
import com.hig.risk.service.IRiskSelfInspectionContentService;

/**
 * 排查内容Service业务层处理
 * 
 * @author scp
 * @date 2024-11-23
 */
@Service
public class RiskSelfInspectionContentServiceImpl implements IRiskSelfInspectionContentService 
{
    @Autowired
    private RiskSelfInspectionContentMapper riskSelfInspectionContentMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询排查内容
     * 
     * @param id 排查内容ID
     * @return 排查内容
     */
    @Override
    public RiskSelfInspectionContent selectRiskSelfInspectionContentById(Long id)
    {
        return riskSelfInspectionContentMapper.selectRiskSelfInspectionContentById(id);
    }

    /**
     * 查询排查内容列表
     * 
     * @param riskSelfInspectionContent 排查内容
     * @return 排查内容
     */
    @Override
//    @DataScope(deptAlias = "d")
    public List<RiskSelfInspectionContent> selectRiskSelfInspectionContentList(RiskSelfInspectionContent riskSelfInspectionContent)
    {
        return riskSelfInspectionContentMapper.selectRiskSelfInspectionContentList(riskSelfInspectionContent);
    }

    /**
     * 新增排查内容
     * 
     * @param riskSelfInspectionContent 排查内容
     * @return 结果
     */
    @Override
    public int insertRiskSelfInspectionContent(RiskSelfInspectionContent riskSelfInspectionContent)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        riskSelfInspectionContent.setCreateBy(loginUser.getUser().getUserName());
        riskSelfInspectionContent.setDeptId(loginUser.getUser().getDeptId());
        riskSelfInspectionContent.setCreateTime(DateUtils.getNowDate());
        return riskSelfInspectionContentMapper.insertRiskSelfInspectionContent(riskSelfInspectionContent);
    }

    /**
     * 修改排查内容
     * 
     * @param riskSelfInspectionContent 排查内容
     * @return 结果
     */
    @Override
    public int updateRiskSelfInspectionContent(RiskSelfInspectionContent riskSelfInspectionContent)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        riskSelfInspectionContent.setUpdateBy(loginUser.getUser().getUserName());
        riskSelfInspectionContent.setUpdateTime(DateUtils.getNowDate());
        return riskSelfInspectionContentMapper.updateRiskSelfInspectionContent(riskSelfInspectionContent);
    }

    /**
     * 批量删除排查内容
     * 
     * @param ids 需要删除的排查内容ID
     * @return 结果
     */
    @Override
    public int deleteRiskSelfInspectionContentByIds(Long[] ids)
    {
        return riskSelfInspectionContentMapper.deleteRiskSelfInspectionContentByIds(ids);
    }

    /**
     * 删除排查内容信息
     * 
     * @param id 排查内容ID
     * @return 结果
     */
    @Override
    public int deleteRiskSelfInspectionContentById(Long id)
    {
        return riskSelfInspectionContentMapper.deleteRiskSelfInspectionContentById(id);
    }

    @Override
    public List<RiskSelfInspectionContent> selectAllContentList(RiskSelfInspectionContent riskSelfInspectionContent)
    {
        return riskSelfInspectionContentMapper.selectRiskSelfInspectionContentList(riskSelfInspectionContent);
    }
}
